-- cannon_skill
-- Created by cheny3 Aug/03/2016
-- 主炮攻击后触发：天空战属性释放技能
-- ([2:100])代表100%概率释放技能2

return {
    -- 空属性
    getEmptyProp = function()
        return {};
    end,

    -- 合并属性
    mergeSkyProp = function(data, addon)
        local result = {};

        if not data then
            result = table.deepcopy(addon);
        else
            result = table.deepcopy(data);

            for _, skillId in pairs(addon) do
                local value = addon[skillId];

                if not result[skillId] then
                    result[skillId] = value;
                else
                    result[skillId] = value + (result[skillId] or 0);
                end
            end
        end

        return result;
    end,

    parseDesc = function(desc, data)
        for _, skillId in ipairs(table.keys(data)) do
            -- 触发率
            local rate = math.modf(data[skillId] / 10);
            desc = string.gsub(desc, "{cast_rate}", rate, 1);

            -- 释放指定技能，需要对该技能解析一次描述
            desc = SkyShipSkillM.parseDesc(skillId, desc);
        end

        return desc;
    end,
};